package fr.ece.ing4.inf442.cours2;


public class DemoWaitNotify {

	static Counter c = new Counter();

	public static void main(String[] args) throws InterruptedException {
		new Thread() {
			@Override
			public void run() {
				synchronized (DemoWaitNotify.c) {
					while (!DemoWaitNotify.c.isInitialized()) {
						try {
							DemoWaitNotify.c.wait();
						} catch (InterruptedException e) {
						}
					}
					DemoWaitNotify.c.increment();
					DemoWaitNotify.c.notify();
				}
			}
		}.start();
		synchronized (DemoWaitNotify.c) {
			DemoWaitNotify.c.init(10);
			DemoWaitNotify.c.notify();
			DemoWaitNotify.c.wait();
		}
		System.out.println(DemoWaitNotify.c.value());
	}

}
